#include "StdAfx.h"
#include <assert.h>
#include "UINcFrame.h"
#include "UIImgGdiplus.h"

CUINcFrame::CUINcFrame( HWND hParent, UINT uImgID, IMGDIRECTION imgDir, UINT uImgCount ): m_hParent( hParent ), m_iNcCurStatus( NC_ACTIVE )
{
    m_pImg = new CUIImgGdiplus();
    m_pImg->LoadImg( uImgID, imgDir, uImgCount );
}


CUINcFrame::~CUINcFrame( void )
{
    if ( NULL != m_pImg )
    {
        delete m_pImg;
        m_pImg = NULL;
    }
}

void CUINcFrame::SetPosition( int x, int y )
{
    m_rcBorder.left = x;
    m_rcBorder.top = y;
    m_pImg->SetPosition( x, y );
}

void CUINcFrame::SetSize( int iWidth, int iHeight )
{
    m_rcBorder.right = iWidth;
    m_rcBorder.bottom = iHeight;
    m_pImg->SetSize( iWidth, iHeight );
}

RECT CUINcFrame::GetBorder()const
{
    RECT rc;
    ::SetRect( &rc, m_rcBorder.left, m_rcBorder.top, m_rcBorder.left + m_rcBorder.right, m_rcBorder.top + m_rcBorder.bottom );
    return rc;
}

void CUINcFrame::SetCurStatus( int iCurStatus )
{
    assert( iCurStatus >= NC_ACTIVE && iCurStatus <= NC_NOACTIVE );
    m_iNcCurStatus = iCurStatus;
}

void CUINcFrame::Draw( HDC hDC )
{
    if ( NC_ACTIVE == m_iNcCurStatus )
    {
        m_pImg->SetCurStatus( NC_ACTIVE );
        m_pImg->Draw( hDC );
    }
    else
    {
        m_pImg->SetCurStatus( NC_NOACTIVE );
        m_pImg->Draw( hDC );
    }
}
